<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style type="text/css">
			.select_option{
				width: 180px;
				z-index: 1;
				position: absolute;
				display: none;
			}
			.select_showbox{
				width: 175px;
				display: none;
			}
			
			select{
    			display: block;
			}
		</style>
		<link type="text/css" rel="stylesheet" href="${ctx}/static/tools/jquery-validationEngine/validationEngine.jquery.css"></link>
	</head>
	<body>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine.js"></script>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine-cn.js"></script>
		<div class="cinema_tip">
		    <div class="cinema_subject clearfix">
		        <div class="cinema_title">
		            <a href="javascript:void(0);">用户中心</a> >
		            <a id="userinfo_list_href" href="${ctx}/sys/user/list">用户管理</a> >
		            <a href="javascript:void(0);" class="cinema_option">编辑用户信息</a>
		        </div>
		        <!-- <a onclick="javascript:history.back(-1);" class="movie_return">返回列表</a> -->
		        <a href="${ctx}/sys/user/listUser" class="movie_return">返回列表</a>
		    </div>
		</div>
		<div class="cinema_list">
			<form class="form-horizontal" onsubmit="return sysProInfoModify();" id="userForm"  name="userForm" method="post">
				<input type="hidden" id="id" name="user_id" value="${res.user_id}">
				<div class="movie_list">
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p>用户名：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="loginName" type="text" name="loginName" value="${res.loginName}" class="validate[required,maxSize[50]]" maxlength="50" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">姓名：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="userName" type="text" name="userName" value="${res.userName}" class="width_320" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">电子邮件：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="email" type="text" name="email" value="${res.email}" class="width_320" maxlength="50" />
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">用户角色：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed positionSelect">
							<select name="roleId" id="roleId">
							<option  value="">请选择角色</option>
							<c:forEach var="roleRes" items="${roleRs.data.rows}" varStatus="status">
								<option value="${roleRes.role_id}" <c:if test="${res.roleId==roleRes.role_id}">selected</c:if>>${roleRes.roleName}</option>
							</c:forEach>
							</select>	
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">状态: </p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed positionSelect">
								<select id="status" name="status">
										<option class="department_opt" value="1" <c:if test="${res.status==1}">selected</c:if>>未审批</option>
										<option class="department_opt" value="2" <c:if test="${res.status==2}">selected</c:if>>已审批</option>
								</select>
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">项目名：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
							<select id="projectID" name="projectID">
							<c:forEach var="projectRes" items="${projectRes.data}" varStatus="status">
								<option value="${projectRes.proId}" <c:if test="${res.projectID==projectRes.proId}">selected</c:if>>${projectRes.name}</option>
							</c:forEach>
							</select>
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">工段：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
							<select id="segmentID" name="segmentID">
							<c:forEach var="segment" items="${sectionRes}" varStatus="status">
								<option value="${segment.secId}" <c:if test="${res.segmentID==segment.secId}">selected</c:if>>${segment.name}</option>
							</c:forEach>
							</select>
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">职务：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">${res.postName}</div>
						</dd>
					</dl>
					
					
					<div class="clearfix"></div>
					
					<a class="movie_continue">
						<input type="submit" name="submit" id="submit" value="提交" class="cinema_inquiry" />
					</a>
				</div>
				
			</form>
		</div>
		<script type="text/javascript">
			//项目基本信息修改
			function sysProInfoModify(){
				document.userForm.action = "${ctx}/sys/user/update";
				//jQuery("#sysModifyForm").action="${ctx}/sys/user/update";
				jQuery("#userForm").submit();
				/*if($("#sysProInfoModifyForm").validationEngine("validate")){
					$.ajax({
				        type: "POST",
				        dataType: "json",
				        async: false,
				        url: '${ctx}/sys/sysProjectMan/ProjectInfo/modify',
				        data: $('#sysProInfoModifyForm').serialize(),
				        success: function (data) {
				        	if(data!=undefined&&data.status!=undefined&&data.status.trim()=='0'){
				        		result = true;
				        		alert("修改成功！");
				        		window.location.href = $("#userinfo_list_href").attr("href");
				        	}else{
					        	result = false;
				        		alert(data.error);
				        	}
				        },
				        error: function(data) {
				        	result = false;
			        		alert(data.data);
				         }
				    });
				}
				return false;*/
			}
			
			$(function(){
			    $("#projectID").live("change",function(){
			    	var proId = $("#projectID").val();
			    	$.ajax({
	    		        async: true,
	    		        type:"POST",
	    		        url: "${ctx}/sys/sysProjectMan/SectionInfo/sectionByProId/"+proId,
	    		        dataType: "json",
	    		        headers : {  
	                        'Content-Type' : 'application/json;charset=utf-8'  
	                    },
	                    
	                    success : function(data) {
	                		if (data != undefined && data.status != undefined
	                				&& data.status.trim() == '0') {
	                			result = true;
	                			$("#segmentID").empty();
	                			$("#segmentID").prepend("<option value='0'>请选择工段　</option>");
	                			for(var i=0;i<data.data.length;i++){
	                				//alert(data.data[i].name);
	                				var txt = "<option value='"+data.data[i].secId+"'>"+data.data[i].name+"</option>";
	                				$("#segmentID").append(txt);
	                			}
	                		} else {
	                			result = false;
	                			alert(data.error);
	                		}
	                	},
	    			},"json");  
			    });
			});
			//$("#sysUserInfoModifyForm").validationEngine();
		</script>
	</body>
</html>